/**
 * 地址相关
 * @author [donghui]
 */
const $http = require('../utils/http.js'), api = require('../config/api.js')

/**
 * 获取用户地址集合，按定位店铺距离排序
 */
var _getUserAddressList = function (params) {
  return $http.get(api.GET_USER_ADDRESS_LIST, params)
}

/**
 * 获取门店信息，根据距离远近排序
 */
var _getShopAddressList = function (params) {
  return $http.get(api.GET_SHOP_ADDRESS_LIST, params)
}

/**
 * 保存收货地址
 */
var _saveXcxAddress = function (params) {
  return $http.get(api.SAVE_USER_ADDRESS, params)
}

/**
 * 根据经纬度，获取最近一家店铺
 */
var _getNearestShop = function (params) {
  return $http.get(api.GET_NEAREST_SHOP, params)
}

/**
 * 删除用户地址
 */
var _deleteXcxAddress = function (params) {
  return $http.get(api.DELETE_USER_ADDRESS, params)
}

/**
 * 获取用户地址详情
 */
var _getXcxAddress = function (params) {
  return $http.get(api.GET_ADDRESS_INFO_BY_ID, params)
}

/**
 * 获取店铺详情
 */
var _getShopById = function (params) {
  return $http.get(api.GET_SHOP_BY_SHOP_ID, params)
}

/**
 * 订单判断地址可用
 */
var _listXcxAddressByShop = function (params) {
  return $http.get(api.GET_ORDER_ADDRESS, params)
}

module.exports = {
  getUserAddressList: _getUserAddressList,
  getShopAddressList: _getShopAddressList,
  saveXcxAddress: _saveXcxAddress,
  getNearestShop: _getNearestShop,
  deleteXcxAddress: _deleteXcxAddress,
  getXcxAddress: _getXcxAddress,
  getShopById: _getShopById,
  listXcxAddressByShop: _listXcxAddressByShop
}